const { app, ipcMain, BrowserWindow } = require('electron')
const path = require('path')

const { createMainWindow } = require('./window_main.js')

let start

const createStartWindow = () => {
  start = new BrowserWindow({
    width: 375,
    height: 667,
    resizable: false, 
    autoHideMenuBar: true,
    frame: false,
    webPreferences: {
      preload: path.join(__dirname, '../preload/preload.js') 
    }
  })

  start.loadURL('http://localhost:5173')
  // start.webContents.openDevTools()

  start.on('closed', () => {
    start = null
  }) 
}

app.on('ready', () => {
  ipcMain.handle('start-invoke', () => {
    start.close()
    createMainWindow()
  })
})

module.exports = {
  createStartWindow
}